<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="all,follow">

    <title>用户管理</title>
    <link rel="shortcut icon" href="/img/favicon.ico">
    
    <!-- global stylesheets -->
    <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <link rel="stylesheet" href="/font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/font-icon-style.css">
    <link rel="stylesheet" href="/css/style.default.css" id="theme-stylesheet">
    <script src="/js/jquery-3.4.1.js"></script>
    <script type="text/javascript">
      function f(){
      $(".search-input").on("input propertychange", function() {
        var queryStr = $.trim($(".search-input").val());
        if(queryStr === ''){
          $(".list-content li").show();
        }else{
        // 以下是匹配某些列的内容，如果是匹配全部列的话就把find()和.parent()去掉即可
          $(".list-content li").hide().find(".code, .name").filter(":contains('"+queryStr+"')").parent("li").show();
          //$(".list-content").refresh(); //重新刷新列表把隐藏的dom结构去掉。
        }
      });
    }
      function addUser() {
          var loginName = document.forms["myForms"]["loginName"].value;
          var type = document.forms["myForms"]["type"].value;
          var password = document.forms["myForms"]["password"].value;
          var realName = document.forms["myForms"]["realName"].value;
          var phoneNum = document.forms["myForms"]["phoneNum"].value;
          var email =document.forms['myForms']['email'].value;
          var flagPass = false;
          if (loginName==""){
              alert("用户名不能为空");
              return false;
          }
          if (type=="#"){
              alert("用户类型不能为空");
              return false;
          }
          if (password==""){
              alert("密码不能为空");
              return false;
          }

          if (phoneNum==""){
              alert("手机号码不能为空");
              return false;
          }
          if (email==""){
              alert("电子邮箱不能为空");
              return false;
          }
          $.ajax({
              url:"/login/checkLoginName",
              type:"post",
              data:{"loginName":loginName},
              async:false,
              success:function(result){
                  if(result.code == 200){
                      alert("用户存在");
                      flagPass=false;
                  }else {
                      flagPass=true;
                  }
              }
          });
            return flagPass;
      }
      function editUser() {
          var type = document.forms["myEdit"]["type"].value;
          var id = document.forms["myEdit"]["id"].value;
          var password = document.forms["myEdit"]["password"].value;
          var realName = document.forms["myEdit"]["realName"].value;
          var phoneNum = document.forms["myEdit"]["phoneNum"].value;
          var email =document.forms['myEdit']['email'].value;
          if (type=="#"){
              alert("用户类型不能为空");
              return false;
          }
          if (password==""){
              alert("密码不能为空");
              return false;
          }
          if (password.length<6){
              alert("密码长度不低于6位");
              return false;
          }
          if (realName==""){
              alert("真实姓名不难为空");
          }
          if (phoneNum==""){
              alert("手机号码不能为空");
              return false;
          }
          if (email==""){
              alert("电子邮箱不能为空");
              return false;
          }

          alert("ID："+id+" 用户"+"修改成功");

      }
      function ResetPwd() {
          var id = document.forms["resetPwd"]["id1"].value;
          var newPassword = document.forms["resetPwd"]["newPassword"].value;
          var checkPassword = document.forms["resetPwd"]["checkPassword"].value;
          console.log("id");
          if (newPassword==""){
              alert("密码不能为空");
              return false;
          }
          if (newPassword.length<6){
              alert("密码长度不低于6位");
              return false;
          }
          if (newPassword!=checkPassword){
              alert("两次输入的密码不一致");
              return false;
          }
          alert("ID："+id+" 用户"+"修改密码成功");
      }


    </script>
    <script type="text/javascript">
        // $("#updateUser").modal("hide");

        function Values(id) {
            $("#id").val(id);
        }
        function Reset(id1) {
            $("#id1").val(id1);
        }
        function  deleteUser(id) {
            var url ="/platForm/deleteUser?id="+id;
            window.location =url;
        }
        function  ice(id) {
            var url ="/platForm/ice?id="+id;
            window.location =url;
        }
        function  unIce(id) {
            var url ="/platForm/unIce?id="+id;
            window.location =url;
        }


    </script>

    <!-- Core stylesheets -->

</head>

<body> 
<!--====================================================
                        PAGE CONTENT
======================================================-->
    <div class="content-inner form-cont">
            <div class="row">
                <div class="col-md-12">

                    <!--***** BASIC FORM *****-->
                    <div class="card form" id="form1">
                        <div class="card-header">
                            <h3>用户查询</h3>
                        </div>
                        <br>


                        <form action="/platForm/findByNameType" method="post">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="example-text-input" style="width: 85px;" class=" col-form-label">真实姓名</label>
                                        <div class="col-9">
                                            <input name="realName" class="form-control" type="text" >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label style="width: 85px;"  class=" col-form-label">用户类型</label>
                                        <div class="col-9" th:if="${session.user.getType()=='超级管理员'}">
                                            <select class="form-control" name="option">
                                                <option value="#">选择类型</option>
                                                <option value="2">普通用户</option>
                                                <option value="3">服务商</option>
                                                <option value="4" >管理员</option>
                                            </select>
                                        </div>
                                        <div class="col-9" th:if="${session.user.getType()=='管理员'}">
                                            <select class="form-control" name="option">
                                                <option value="#">选择类型</option>
                                                <option value="2">普通用户</option>
                                                <option value="3">服务商</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <button type="submit" class="btn btn-general btn-blue mr-2" onclick="loadPage()">查询</button>
                                    <button type="reset" class="btn btn-general btn-white">重置</button>
                                </div>
                            </div>
                        </form>



                    </div>
                </div>
            </div>

        <div class="page-content d-flex align-items-stretch">

            <div class="content-inner chart-cont">
                <!--***** CONTENT *****-->
                <div class="row">
                    <button type="button" class="btn btn-outline-primary" data-toggle="modal" data-target="#newUser">新增用户</button>

                    <table class="table table-hover">
                        <thead>
                        <tr class="bg-info text-white">
                            <th>ID</th>
                            <th>用户名</th>
                            <th>用户类型</th>
                            <th>真实姓名</th>
                            <th>手机号码</th>
                            <th>邮箱</th>
                            <th>账号状态</th>
                            <th style="text-align: center;">操作</th>
                        </tr>
                        </thead>


                        <tbody id="table-detail">
                            <tr th:each="user: ${lists}">
                                <th scope="row" th:text="${user.id}"></th>
                                <td th:text="${user.loginName}"></td>
                                <td th:text="${user.type}"></td>
                                <td th:text="${user.realName}"></td>
                                <td th:text="${user.phoneNum}"></td>
                                <td th:text="${user.email}"></td>
                                <td th:text="${user.status}"></td>
                                <td>
  <!--      <a href="#" data-toggle="modal" data-target="#updateUser" th:οnclick="'javascript:Values('+${user.id}+',\''+${user.loginName}+'\',\''+${user.realName}+'\',\''+${user.phoneNum}+'\',\''+${user.email}+'\')'">编辑|</a>-->
                                    <button th:onclick="|Values('${user.id}')|"  class="btn btn-outline-primary" data-target="#updateUser" data-toggle="modal">编辑</button>
                                    <button th:onclick="|deleteUser('${user.id}')|"  class="btn btn-outline-primary" >删除</button>
                                    <button th:onclick="|ice('${user.id}')|"  class="btn btn-outline-primary">冻结</button>
                                    <button th:onclick="|unIce('${user.id}')|"  class="btn btn-outline-primary">解冻</button>
                                    <button th:onclick="|Reset('${user.id}')|"  type="button" class="btn btn-outline-primary" data-target="#newPassword" data-toggle="modal">密码重置</button>
                                </td>
                            </tr>


                        </tbody>




                    </table>

                    <div  class="c-pages">
                        <div class="cp-item">
                            <span>共</span>
                            <span id="cp-count">0</span>
                            <span>条</span>
                        </div>
                        <div class="cp-item">
                            <span id="curr-page">1</span>
                            <span>/</span>
                            <span id="total-page">1</span>
                        </div>
                        <div class="cp-item">
                            <button id="home" class="btn btn-outline-primary">首页</button>
                            <button id="prev" class="btn btn-outline-primary">上页</button>
                            <input type="number" id="goToPage" />
                            <button id="goTo" class="btn btn-outline-primary">转到</button>
                            <button id="next" class="btn btn-outline-primary">下页</button>
                            <button id="last" class="btn btn-outline-primary">尾页</button>
                        </div>

                    </div>
                </div>
            </div>

        </div>
    </div>
<!-- 新增用户模态框（Modal） -->
<div class="modal fade" id="newUser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    新增用户
                </h4>
            </div>
            <div class="modal-body">

<!--                新增用户   -->

                <form action="/platForm/addUser" onsubmit="return addUser()" name="myForms">
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">用户名</label>
                    <div class="col-9">
                        <input name="loginName" class="form-control" type="text">
                    </div>
                </div>
                <div class="form-group row">
                    <label style="width: 85px;margin-left: 20px;"  class=" col-form-label">用户类型</label>

                    <div class="col-9" th:if="${session.user.getType()=='管理员'}">
                        <select class="form-control" name="type">
                            <option value="#">选择类型</option>
                            <option value="普通用户">普通用户</option>
                            <option value="服务商">服务商</option>
                        </select>
                    </div>
                    <div class="col-9" th:if="${session.user.getType()=='超级管理员'}">
                        <select class="form-control" name="type">
                            <option value="#">选择类型</option>
                            <option value="普通用户">普通用户</option>
                            <option value="服务商">服务商</option>
                            <option value="管理员">管理员</option>
                        </select>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">密码：</label>
                    <div class="col-9">
                        <input name="password" class="form-control" type="password">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">真实姓名：</label>
                    <div class="col-9">
                        <input  class="form-control" type="text" name="realName">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">手机号：</label>
                    <div class="col-9">
                        <input  class="form-control" type="text" name="phoneNum">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">邮箱：</label>
                    <div class="col-9">
                        <input class="form-control" type="text" name="email">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">提交</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                </div>
                </form>

            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>

<!-- 编辑用户模态框（Modal） -->
<div class="modal fade" id="updateUser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    编辑用户
                </h4>
            </div>

            <div class="modal-body">
                <form action="/platForm/edit" onsubmit="return editUser()" name="myEdit">
                <input type="hidden" id="id" name="id" value="">
<!--                <div class="form-group row">-->
<!--                    <label for="example-text-input" style="width: 85px; margin-left: 20px;" class=" col-form-label">用户名：</label>-->
<!--                    <div class="col-9">-->
<!--                        <input name="loginName" class="form-control" type="text" value="">-->
<!--                    </div>-->
<!--                </div>-->

                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">用户类型：</label>
                    <div class="col-9">
                        <select class="form-control" name="type">
                            <option value="#">选择类型</option>
                            <option value="普通用户">普通用户</option>
                            <option value="服务商">服务商</option>
                            <option value="管理员">管理员</option>
                        </select>
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">密码：</label>
                    <div class="col-9">
                        <input name="password" class="form-control" type="password"  >
                    </div>
                </div>
<!--                <div class="form-group row">-->
<!--                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">再次输入密码：</label>-->
<!--                    <div class="col-9">-->
<!--                        <input name="checkPwd" class="form-control" type="password"  >-->
<!--                    </div>-->
<!--                </div>-->
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">真实姓名：</label>
                    <div class="col-9">
                        <input  class="form-control" type="text"   name="realName">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">手机号：</label>
                    <div class="col-9">
                        <input  class="form-control" type="text"  name="phoneNum">
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">邮箱：</label>
                    <div class="col-9">
                        <input class="form-control" type="text"  name="email">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">提交</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                </div></form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>


<!-- 重置密码模态框（Modal） -->
<div class="modal fade" id="newPassword" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    重置密码
                </h4>
            </div>
            <div class="modal-body">

                <form action="/platForm/resetPwdById" name="resetPwd" onsubmit="return ResetPwd()">
                <input type="hidden" id="id1" name="id1" value="">
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">新密码：</label>
                    <div class="col-9">
                        <input name="newPassword" class="form-control" type="password" >
                    </div>
                </div>
                <div class="form-group row">
                    <label for="example-text-input" style="width: 85px;margin-left: 20px;" class=" col-form-label">再次输入：</label>
                    <div class="col-9">
                        <input name="checkPassword" class="form-control" type="password">
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="submit" class="btn btn-primary">提交</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                </div>
                </form>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>


    <!--Global Javascript -->
    <script src="/js/jquery.min.js"></script>
    <script src="/js/popper/popper.min.js"></script>
    <script src="/js/tether.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/jquery.cookie.js"></script>
    <script src="/js/jquery.validate.min.js"></script> 
    <script src="/js/chart.min.js"></script> 
    <script src="/js/front.js"></script> 
    <script src="/js/forpage.js"></script>
</body>

</html>